import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: () => import('../views/login.vue')
  },
  {
    path: '/welcome',
    component: () => import('../views/welcome.vue'),
    children:[
      //超管的
      {
        path: '/yhgl',
        component: () => import('../views/chaoguan/yhgl.vue')
      },
      {
        path: '/zdwh',
        component: () => import('../views/chaoguan/zdwh.vue')
      },
      {
        path: '/sjgl',
        component: () => import('../views/chaoguan/sjgl.vue')
      },
      {
        path: '/rjsj',
        component: () => import('../views/chaoguan/rjsj.vue')
      },
      //普通管理员的
      {
        path: '/xxmh',
        component: () => import('../views/ptguan/xxmh.vue')
      },
      {
        path: '/xqzl',
        component: () => import('../views/ptguan/xqzl.vue')
      },
      {
        path: '/tzgl',
        component: () => import('../views/ptguan/tzgl.vue')
      },
      {
        path: '/wgmh',
        component: () => import('../views/ptguan/wgmh.vue')
      },
      {
        path: '/xqjd',
        component: () => import('../views/ptguan/xqjd.vue')
      },
      {
        path: '/xxcx',
        component: () => import('../views/ptguan/xxcx.vue')
      },
      {
        path: '/wggl',
        component: () => import('../views/ptguan/wggl.vue')
      },
      {
        path: '/rwgl',
        component: () => import('../views/ptguan/rwgl.vue')
      }, 
      {
        path: '/menhu',
        component: () => import('../views/lingdao/xxmh.vue')
      }, 
      {
        path: '/bigscreen',
        component: () => import('../views/lingdao/bigscreen.vue')
      }, 
      {
        path: '/searchinfo',
        component: () => import('../views/lingdao/search.vue')
      }, 
      {
        path: '/qwer',
        component: () => import('../views/zhuhu/qwer.vue')
      }, 
      {
        path: '/gonggao',
        component: () => import('../views/zhuhu/gonggao.vue')
      }, 
      {
        path: '/yijian',
        component: () => import('../views/zhuhu/yijian.vue')
      }, 
    ]
  },

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, path, next) => {
  if (to.path == "/") {
    next()
  } else {
    if (sessionStorage.getItem("token")) {
      next()
    } else {
      next("/")
    }
  }
})

export default router
